package com.bdqn.tour.service.impl;

import com.bdqn.tour.dao.GyhAddUserInfoDao;
import com.bdqn.tour.dao.GyhLoginDao;
import com.bdqn.tour.dao.impl.GyhAddUserInfoDaoImpl;
import com.bdqn.tour.dao.impl.GyhLoginDaoImpl;
import com.bdqn.tour.pojo.User;
import com.bdqn.tour.service.GyhAddUserInfoService;
import com.bdqn.tour.util.MD5Util;

public class GyhAddUserInfoServiceImpl implements GyhAddUserInfoService {

    //调用Dao层
    GyhAddUserInfoDao dao= new GyhAddUserInfoDaoImpl();
    GyhLoginDao CheckDao=new GyhLoginDaoImpl();
    @Override
    public int addUserInfo(String phone, String password, String name) {
        //给密码加密
        password= MD5Util.md5(password,5);

        return dao.addUserInfo(phone,password,name);
    }

    @Override
    public int addMsgUserInfo(String phone, String password, String username, String status) {
        //判断数据库里有没有相同的手机号码
        User user = CheckDao.getLogin(phone);
        //判断数据库里有没有相同的手机号码
        if (user != null){
            return -1;
        }


        //给密码加密
        password= MD5Util.md5(password,5);
        return dao.addMsgUserInfo(phone,password,username,status);
    }
}
